import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_woo_2025/common/index.dart';
import 'package:get/get.dart';

import 'global.dart';

void main() async {
  await Global.init();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      
      //设计稿中设备的尺寸（单位随意，建议dp，但在使用过程中必须保持一致）
      designSize: const Size(414, 896),
      //支持分屏尺寸
      splitScreenMode: false,
      //是否根据宽度、高度中的最小值适配文字
      minTextAdapt: false,

      //构建
      builder: (context, child) => AdaptiveTheme(
        //样式
        light: AppTheme.light,
        dark: AppTheme.dark,
        initial: ConfigService.to.themeMode,
        debugShowFloatingThemeButton: true,
      
        //构建
        builder:(theme, darkTeme) => GetMaterialApp(
          title: 'Flutter Demo',
          
          //主题
          theme: theme,
          darkTheme: darkTeme,
        
          //路由
          initialRoute: RouteNames.systemSplash,
          getPages: RoutePages.list,
          navigatorObservers: [RoutePages.observer],
        
          //多语言
          translations: Translation(), //词典
          localizationsDelegates: Translation.localizationsDelegates, //代理
          supportedLocales: Translation.supportedLocales, //支持的语言
          locale: ConfigService.to.locale, //当前语言种类
          fallbackLocale: Translation.fallbackLocale, //默认语言

          builder: (context, child) {
            // 不随系统字体缩放比例
            return MediaQuery(
              data: MediaQuery.of(context).copyWith(textScaler: const TextScaler.linear(1.0)),
              child: child!,
            );
          },
        ),
      ),
    );
  }
}
